package com.douyang.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import com.douyang.VO.AuthClientListVO;
import com.douyang.base.model.PageResult;
import com.douyang.base.model.Result;
import com.douyang.dto.ApplyClientDTO;
import com.douyang.dto.AuthClientStatusDTO;
import com.douyang.dto.GetAuthClientListDTO;
import com.douyang.service.AuthClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoma
 * @since 2025-04-04
 */
@RestController
@RequestMapping("/user/authClient")
public class AuthClientController {
    @Autowired
    private AuthClientService authClientService;


    @SaCheckRole("admin")
    @PostMapping("/getAppInfoList")
    public Result<PageResult<AuthClientListVO>> getAuthClientList(@RequestBody GetAuthClientListDTO getAuthClientListDTO) {
        return Result.success(authClientService.getAuthClientList(getAuthClientListDTO));
    }

    @SaCheckRole("admin")
    @PostMapping("/audit")
    public Result<String> audit(@RequestBody AuthClientStatusDTO authClientStatusDTO) {
        authClientService.audit(authClientStatusDTO);

        return Result.success("ok");
    }

    @PostMapping("/applyClient")
    public Result<String> appClient(@RequestBody ApplyClientDTO applyClientDTO) {
        authClientService.appClient(applyClientDTO);
        return Result.success("ok");
    }

    @PostMapping("/getMyApplications")
    public Result<PageResult<AuthClientListVO>> getMyApplications(@RequestBody GetAuthClientListDTO getAuthClientListDTO){
        return Result.success(authClientService.getMyApplications(getAuthClientListDTO));
    }
}
